package com.edu.exam.entity.assessment.technical;

import com.edu.exam.enums.assessment.technical.CheckType;
import com.edu.exam.enums.assessment.technical.CheckStatus;
import com.edu.exam.enums.assessment.technical.ComparisonScope;
import com.edu.exam.enums.assessment.technical.RecommendationType;
import com.edu.exam.enums.assessment.technical.SimilarityLevel;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import java.time.LocalDateTime;

/**
 * 试卷查重记录实体类
 * 所属模块：B-02 题库管理模块
 * 对应数据库表：question_check_record
 *
 * 根据B-03-10试卷查重子模块设计文档实现
 * 管理试卷查重的详细记录和结果信息，支持实时查重、审核查重和批量查重等多种查重类型。
 *
 * @author System
 * @version 1.0.0
 */

@Entity
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class QuestionCheckRecord {

    /**
     * 主键ID
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 试卷ID
     */
    @Column(name = "paper_id", nullable = false)
    private Long paperId;

    /**
     * 试卷标题
     */
    @Column(name = "paper_title", length = 200)
    private String paperTitle;

    /**
     * 查重类型
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "check_type", nullable = false, length = 20)
    private CheckType checkType;

    /**
     * 查重范围
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "comparison_scope", nullable = false, length = 20)
    private ComparisonScope comparisonScope;

    /**
     * 查重阈值
     */
    @Column(name = "check_threshold", precision = 4, scale = 3)
    private Double checkThreshold;

    /**
     * 最终相似度
     */
    @Column(name = "final_similarity", precision = 5, scale = 4)
    private Double finalSimilarity;

    /**
     * 相似度等级
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "similarity_level", length = 20)
    private SimilarityLevel similarityLevel;

    /**
     * 相似试卷总数
     */
    @Column(name = "similar_paper_count")
    private Integer similarPaperCount;

    /**
     * 高度相似试卷数
     */
    @Column(name = "highly_similar_count")
    private Integer highlySimilarCount;

    /**
     * 中度相似试卷数
     */
    @Column(name = "moderately_similar_count")
    private Integer moderatelySimilarCount;

    /**
     * 低度相似试卷数
     */
    @Column(name = "low_similarity_count")
    private Integer lowSimilarityCount;

    /**
     * 处理建议类型
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "recommendation_type", length = 20)
    private RecommendationType recommendationType;

    /**
     * 处理建议详细内容
     */
    @Column(name = "recommendation_message", length = 1000)
    private String recommendationMessage;

    /**
     * 查重状态
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "check_status", nullable = false, length = 20)
    private CheckStatus checkStatus;

    /**
     * 错误信息
     */
    @Column(name = "error_message", length = 1000)
    private String errorMessage;

    /**
     * 分析耗时（毫秒）
     */
    @Column(name = "analysis_time")
    private Long analysisTime;

    /**
     * 查重时间
     */
    @Column(name = "check_time", nullable = false)
    private LocalDateTime checkTime;

    /**
     * 操作人员ID
     */
    @Column(name = "operator_id", length = 50)
    private Long operatorId;

    /**
     * 操作人员姓名
     */
    @Column(name = "operator_name", length = 100)
    private String operatorName;

    /**
     * 创建时间
     */
    @CreationTimestamp
    @Column(name = "create_time", nullable = false, updatable = false)
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @UpdateTimestamp
    @Column(name = "update_time")
    private LocalDateTime updateTime;

    /**
     * 版本号（用于乐观锁）
     */
    @Version
    @Column(name = "version", nullable = false)
    private Long version;

    /**
     * 是否删除
     */
    @Column(name = "is_deleted", nullable = false)
    @Builder.Default
    private Boolean isDeleted = false;

    
}